addExtensions{
  extensions.add(CreationalContextDestroyer.class);
}
setup{
  Deployment deployment=createDeployment(Service.class,Cat.class,CatService.class,Dog.class,DogService.class);
  bootstrap=new WeldBootstrap();
  bootstrap.startContainer(Environments.SE,deployment).startInitialization().deployBeans().validateBeans().endInitialization();
  manager=bootstrap.getManager(deployment.getBeanDeploymentArchives().iterator().next());
  bind(TestScoped.class,BeanManager.class,manager);
  enricher=new CDIInjectionEnricher();
  injector.get().inject(enricher);
}
teardown{
  bootstrap.shutdown();
}
shouldInjectClassMembers{
  TestClass testClass=new TestClass();
  enricher.injectClass(testClass);
  testClass.testMethod(testClass.dogService,testClass.catService);
}
shouldInjectMethodArguments{
  Method testMethod=TestClass.class.getMethod("testMethod",Service.class,Service.class);
  Object[] resolvedBeans=enricher.resolve(testMethod);
  TestClass testClass=new TestClass();
  testMethod.invoke(testClass,resolvedBeans);
}
shouldInjectMethodArgumentsEvent{
  Method testMethod=TestClass.class.getMethod("testEvent",Event.class,Event.class);
  Object[] resolvedBeans=enricher.resolve(testMethod);
  TestClass testClass=new TestClass();
  testMethod.invoke(testClass,resolvedBeans);
}
shouldReleaseCreationalContext{
  TestClass testClass=new TestClass();
  enricher.injectClass(testClass);
}
shouldInjectMethodArgumentsInstance{
  Method testMethod=TestClass.class.getMethod("testInstance",Instance.class,Instance.class);
  Object[] resolvedBeans=enricher.resolve(testMethod);
  TestClass testClass=new TestClass();
  testMethod.invoke(testClass,resolvedBeans);
}
validateReleased{
}
testMethod{
  Assert.assertNotNull(catService);
  Assert.assertNotNull(dogService);
}
testEvent{
}
testInstance{
}
createDeployment{
  final BeanDeploymentArchive beanArchive=new BeanDeploymentArchive(){
    private ServiceRegistry registry=new SimpleServiceRegistry();
    public ServiceRegistry getServices(){
    public Collection<EjbDescriptor<?>> getEjbs(){
    public BeansXml getBeansXml(){
          @Override protected URLConnection openConnection(          URL u) throws IOException {
            return new URLConnection(u){
              public InputStream getInputStream() throws IOException {
                return new ByteArrayInputStream("<beans/>".getBytes());
        throw new RuntimeException(e);
    public Collection<BeanDeploymentArchive> getBeanDeploymentArchives(){
    public Collection<String> getBeanClasses(){
      Collection<String> beanClasses=new ArrayList<String>();
        beanClasses.add(c.getName());
  final Deployment deployment=new Deployment(){
    public Collection<BeanDeploymentArchive> getBeanDeploymentArchives(){
      return Arrays.asList((BeanDeploymentArchive)beanArchive);
    public ServiceRegistry getServices(){
      return beanArchive.getServices();
    public BeanDeploymentArchive loadBeanDeploymentArchive(    Class<?> beanClass){
  return deployment;
}
getServices{
  return registry;
}
getId{
  return "test.jar";
}
getEjbs{
  return Collections.emptyList();
}
getBeansXml{
      @Override protected URLConnection openConnection(      URL u) throws IOException {
        return new URLConnection(u){
          public void connect() throws IOException {
          public InputStream getInputStream() throws IOException {
            return new ByteArrayInputStream("<beans/>".getBytes());
    throw new RuntimeException(e);
}
openConnection{
    public void connect() throws IOException {
      return new ByteArrayInputStream("<beans/>".getBytes());
}
connect{ }
getInputStream{
  return new ByteArrayInputStream("<beans/>".getBytes());
}
getBeanDeploymentArchives{
  return Collections.emptyList();
}
getBeanClasses{
  Collection<String> beanClasses=new ArrayList<String>();
  for (  Class<?> c : classes) {
    beanClasses.add(c.getName());
}
getBeanDeploymentArchives{
  return Arrays.asList((BeanDeploymentArchive)beanArchive);
}
getServices{
  return beanArchive.getServices();
}
loadBeanDeploymentArchive{ }
getExtensions{
  return Collections.emptyList();
}
